import Vue from 'vue'
import App from './App.vue'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import router from './router' // 导入router实例对象
import store from './store'
import Global from './utils/Global';// 全局函数及变量

Vue.use(ElementUI); // 适用element创建
Vue.use(Global);


Vue.config.productionTip = false

// 注册全局过滤器
// 作用：相对时间过滤器,把时间戳转换成时间
// 格式: 1582638203[秒] --> 2020-02-25 21:43:23
Vue.filter('dateFormat', (dataStr) => {
  var time = new Date(dataStr);
  function timeAdd0 (str) {
    if (str < 10) {
      str = '0' + str;
    }
    return str;
  }
  var y = time.getFullYear();
  var m = time.getMonth() + 1;
  var d = time.getDate();
  var h = time.getHours();
  var mm = time.getMinutes();
  var s = time.getSeconds();
  return y + '-' + timeAdd0(m) + '-' + timeAdd0(d) + ' ' + timeAdd0(h) + ':' + timeAdd0(mm) + ':' + timeAdd0(s);
});

//全局组件
import MyLogin from './components/MyLogin';
import MyRegister from './components/MyRegister';
import MyList from './components/MyList';
Vue.component(MyList.name, MyList);
Vue.component(MyLogin.name, MyLogin);
Vue.component(MyRegister.name, MyRegister);


new Vue({
	router,
	store,
	render: h => h(App)
}).$mount('#app')
